/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.wordplat.quickstart.app;

import ohos.aafwk.ability.Ability;
import ohos.app.Context;

import java.lang.ref.WeakReference;
import java.util.LinkedList;

/**
 * Created by afon on 2017/1/24.
 */
public class AppRuntime {

    /**
     * 静态类型的 Context，你懂的
     */
    private static Context sContext;
    /**
     * 查找当前的 Activity 栈用的
     */
    private static LinkedList<Ability> sActivities = new LinkedList<>();
    /**
     * 快速查找位于栈顶的 Ability 用的
     */
    private static WeakReference<Ability> sActivityStops = new WeakReference<>(null);
    /**
     * 与服务器通信接口版本号。本值会自动读取到 gradle.properties 文件中定义的，不需要手动修改
     */
    private static String serverVersion = "1.0";
    /**
     * 本APP的版本号。本值会自动读取到文件中定义的，不需要手动修改
     */
    private static String appVersion = "1.0.0";

    public static Context getsContext() {
        return sContext;
    }

    public static void setsContext(Context sContext) {
        AppRuntime.sContext = sContext;
    }

    public static LinkedList<Ability> getsActivities() {
        return sActivities;
    }

    public static void setsActivities(LinkedList<Ability> sActivities) {
        AppRuntime.sActivities = sActivities;
    }

    public static WeakReference<Ability> getsActivityStops() {
        return sActivityStops;
    }

    public static void setsActivityStops(WeakReference<Ability> sActivityStops) {
        AppRuntime.sActivityStops = sActivityStops;
    }

    public static String getServerVersion() {
        return serverVersion;
    }

    public static void setServerVersion(String serverVersion) {
        AppRuntime.serverVersion = serverVersion;
    }

    public static String getAppVersion() {
        return appVersion;
    }

    public static void setAppVersion(String appVersion) {
        AppRuntime.appVersion = appVersion;
    }
}
